package com.corona.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Vector2;
import com.corona.Game;
import com.corona.game.util.TextureCache;
import java.util.HashMap;
import java.util.Map;

/* compiled from: Menu.java */
/* access modifiers changed from: package-private */
/* loaded from: pokewilds.jar:com/pkmngen/game/DrawBattleMenuNormal.class */
public class DrawBattleMenuNormal extends Menu {
    Sprite helperSprite;
    public Action.Layer layer = Action.Layer.gui_109;
    Map<String, Vector2> getCoords = new HashMap();
    Sprite arrow = new Sprite(TextureCache.get(Gdx.files.internal("battle/arrow_right1.png")), 0, 0, 5, 7);
    Sprite textBox = new Sprite(TextureCache.get(Gdx.files.internal("battle/battle_menu1.png")), 0, 0, 160, 144);
    Vector2 newPos = new Vector2(73.0f, 24.0f);
    String curr = "tl";

    public DrawBattleMenuNormal(Game game, Action nextAction) {
        this.nextAction = nextAction;
        this.getCoords.put("tr", new Vector2(121.0f, 24.0f));
        this.getCoords.put("tl", new Vector2(73.0f, 24.0f));
        this.getCoords.put("br", new Vector2(121.0f, 8.0f));
        this.getCoords.put("bl", new Vector2(73.0f, 8.0f));
        this.arrow.setPosition(this.newPos.x, this.newPos.y);
    }

    @Override // com.corona.game.Action
    public String getCamera() {
        return "gui";
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        if (!this.disabled) {
            if (game.battle.playerLockedMove != -1) {
                Action attack = new Action(new Object[0]);
                if (game.type == Game.Type.CLIENT) {
                    String attackName = game.player.currPokemon.attacks[game.battle.playerLockedMove];
                    attack.append(new Battle.WaitTurnData(game, null));
                    game.client.sendTCP(new Network.DoBattleAction(game.player.network.id, Battle.DoTurn.Type.ATTACK, attackName));
                }
                attack.append(new Battle.DoTurn(game, Battle.DoTurn.Type.ATTACK, null));
                attack.append(new WaitFrames(game, 4, this));
                game.actionStack.remove(this);
                game.insertAction(attack);
                return;
            }
            if (InputProcessor.upPressed) {
                if (this.curr.equals("bl") || this.curr.equals("br")) {
                    this.curr = "t" + String.valueOf(this.curr.charAt(1));
                    this.newPos = this.getCoords.get(this.curr);
                }
            } else if (InputProcessor.downPressed) {
                if (this.curr.equals("tl") || this.curr.equals("tr")) {
                    this.curr = "b" + String.valueOf(this.curr.charAt(1));
                    this.newPos = this.getCoords.get(this.curr);
                }
            } else if (InputProcessor.leftPressed) {
                if (this.curr.equals("tr") || this.curr.equals("br")) {
                    this.curr = String.valueOf(this.curr.charAt(0)) + "l";
                    this.newPos = this.getCoords.get(this.curr);
                }
            } else if (InputProcessor.rightPressed && (this.curr.equals("tl") || this.curr.equals("bl"))) {
                this.curr = String.valueOf(this.curr.charAt(0)) + "r";
                this.newPos = this.getCoords.get(this.curr);
            }
            if (InputProcessor.aJustPressed) {
                if (this.curr.equals("tl")) {
                    game.insertAction(new PlayMusic("click1", (Action) null));
                    game.insertAction(new WaitFrames(game, 4, new DrawAttacksMenu(new WaitFrames(game, 4, this))));
                    game.actionStack.remove(this);
                } else if (this.curr.equals("bl")) {
                    this.disabled = true;
                    game.actionStack.remove(this);
                    game.insertAction(new PlayMusic("click1", (Action) null));
                    DrawItemMenuGen2 menu = new DrawItemMenuGen2(game, this);
                    menu.disabled = true;
                    game.insertAction(new DrawItemMenu.Intro(this, 6, new DrawWhiteScreen(18, new DrawItemMenu.Intro(menu, 9, new RunCode(() -> {
                        menu.disabled = false;
                    }, menu)))));
                } else if (this.curr.equals("tr")) {
                    this.disabled = true;
                    game.insertAction(new DisplayText.Clear(game, new WaitFrames(game, 3, new DrawPokemonMenu.Intro(new DrawPokemonMenu(game, this)))));
                    game.actionStack.remove(this);
                } else if (this.curr.equals("br")) {
                    Action runAction = new SplitAction(new PlayMusic("click1", (Action) null), null);
                    if (game.battle.oppPokemon.isTrapping) {
                        runAction.append(new DisplayText(game, "Canì escape!", (String) null, (Action) null, this));
                        game.actionStack.remove(this);
                        game.insertAction(runAction);
                        return;
                    }
                    if (game.type == Game.Type.CLIENT) {
                        runAction.append(new Battle.WaitTurnData(game, null));
                        game.client.sendTCP(new Network.DoBattleAction(game.player.network.id, Battle.DoTurn.Type.RUN, ""));
                    }
                    runAction.append(new Battle.DoTurn(game, Battle.DoTurn.Type.RUN, this));
                    game.actionStack.remove(this);
                    game.insertAction(runAction);
                }
            }
            this.textBox.draw(game.uiBatch);
            this.arrow.setPosition(this.newPos.x, this.newPos.y);
            this.arrow.draw(game.uiBatch);
        }
    }
}
